/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Main container - responsive height */
.main-container {
    display: flex;
    height: 450px; /* Default iframe height */
    width: 100%;
    background: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
}

/* Detect if not in iframe and adjust height */
@media (min-height: 500px) {
    .main-container {
        height: 90vh;
    }
}

/* Left Panel - Controls */
.left-panel {
    width: 280px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Product Selection Shelf */
.product-shelf {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.shelf-title {
    font-weight: 600;
    margin-bottom: 10px;
    color: #495057;
    font-size: 14px;
}

.product-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.product-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 8px;
    border: 2px solid #e9ecef;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 11px;
    min-height: 60px;
}

.product-btn:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0,123,255,0.2);
    transform: translateY(-1px);
}

.product-btn.active {
    border-color: #007bff;
    background: #e3f2fd;
    color: #007bff;
}

.product-icon {
    font-size: 20px;
    margin-bottom: 4px;
}

/* User Selection */
.user-selection {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.section-title {
    font-weight: 600;
    margin-bottom: 10px;
    color: #495057;
    font-size: 14px;
}

.user-buttons {
    display: flex;
    gap: 6px;
}

.user-btn {
    flex: 1;
    padding: 8px 4px;
    border: 2px solid #e9ecef;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 11px;
    font-weight: 500;
}

.user-btn:hover {
    border-color: #28a745;
    background: #f8fff9;
}

.user-btn.active {
    border-color: #28a745;
    background: #d4edda;
    color: #155724;
}

/* Controls Section */
.controls-section {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.slider-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.slider-container label {
    font-size: 12px;
    font-weight: 500;
    color: #495057;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e9ecef;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

.btn-primary, .btn-secondary, .btn-hint {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
    transform: translateY(-1px);
}

.btn-hint {
    background: #ffc107;
    color: #212529;
}

.btn-hint:hover {
    background: #e0a800;
    transform: translateY(-1px);
}

/* Center Panel - Visualization */
.center-panel {
    flex: 1;
    background: #ffffff;
    position: relative;
    overflow: hidden;
}

.visualization-area {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to bottom, #e3f2fd 0%, #f5f5f5 100%);
}

/* Human Model */
.human-model {
    position: relative;
    transform-origin: center;
    transition: transform 0.3s ease;
}

.human-figure {
    position: relative;
    width: 60px;
    height: 160px;
}

.head {
    width: 20px;
    height: 20px;
    background: #ffdbcb;
    border-radius: 50%;
    margin: 0 auto 5px;
    border: 2px solid #d4a574;
}

.torso {
    width: 30px;
    height: 50px;
    background: #4a90e2;
    border-radius: 15px 15px 8px 8px;
    margin: 0 auto 5px;
    position: relative;
}

.arm {
    position: absolute;
    width: 8px;
    height: 35px;
    background: #ffdbcb;
    border-radius: 4px;
    top: 25px;
    transition: all 0.3s ease;
}

.left-arm {
    left: -10px;
    transform-origin: top center;
}

.right-arm {
    right: -10px;
    transform-origin: top center;
}

.leg {
    position: absolute;
    width: 10px;
    height: 45px;
    background: #2c3e50;
    border-radius: 5px;
    bottom: 0;
}

.left-leg {
    left: 20px;
}

.right-leg {
    right: 20px;
}

/* Product Visualization */
.product-visual {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.chair-setup {
    position: relative;
}

.chair {
    position: relative;
    transition: all 0.3s ease;
}

.chair-back {
    width: 50px;
    height: 60px;
    background: #8e44ad;
    border-radius: 8px 8px 0 0;
    transform-origin: bottom center;
    transition: transform 0.3s ease;
}

.chair-seat {
    width: 50px;
    height: 8px;
    background: #9b59b6;
    border-radius: 4px;
    margin-top: -2px;
}

.table {
    width: 80px;
    height: 6px;
    background: #8b4513;
    border-radius: 3px;
    margin-top: 20px;
    margin-left: -15px;
    transition: all 0.3s ease;
}

/* Stress Indicators */
.stress-indicators {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.stress-point {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: all 0.3s ease;
    opacity: 0.8;
}

#neckStress {
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
}

#backStress {
    top: 40%;
    left: 50%;
    transform: translateX(-50%);
}

#armStress {
    top: 30%;
    right: 30%;
}

/* Stress level colors */
.stress-low { background: #28a745; }
.stress-medium { background: #ffc107; }
.stress-high { background: #dc3545; }

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.zoom-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: rgba(0,0,0,0.7);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.zoom-btn:hover {
    background: rgba(0,0,0,0.9);
    transform: scale(1.1);
}

/* Right Panel - Feedback */
.right-panel {
    width: 260px;
    background: #f8f9fa;
    border-left: 1px solid #e9ecef;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Feedback Dashboard */
.feedback-dashboard {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.comfort-score {
    text-align: center;
    margin-bottom: 15px;
}

.score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 10px;
}

.score-value {
    font-size: 32px;
    font-weight: bold;
    color: #007bff;
}

.score-label {
    font-size: 12px;
    color: #6c757d;
    margin-top: 2px;
}

.score-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.score-fill {
    height: 100%;
    background: linear-gradient(90deg, #dc3545 0%, #ffc107 50%, #28a745 100%);
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 75%;
}

/* Ergonomic Indicators */
.ergonomic-indicators {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.indicator {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f1f3f4;
}

.indicator-label {
    font-size: 12px;
    color: #495057;
    font-weight: 500;
}

.indicator-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.indicator-status.good {
    background: #d4edda;
    color: #155724;
}

.indicator-status.moderate {
    background: #fff3cd;
    color: #856404;
}

.indicator-status.poor {
    background: #f8d7da;
    color: #721c24;
}

/* Results Section */
.results-section {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    flex: 1;
}

.results-table {
    overflow-x: auto;
}

#resultsTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

#resultsTable th,
#resultsTable td {
    padding: 6px 4px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

#resultsTable th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

/* Comparison Section */
.comparison-section {
    margin-top: auto;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    max-width: 200px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    line-height: 1.4;
}

.tooltip.show {
    opacity: 1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 500px;
    max-height: 70vh;
    overflow-y: auto;
    position: relative;
}

.close {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: #333;
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #333;
}

.modal-content ul {
    margin: 10px 0;
    padding-left: 20px;
}

.modal-content li {
    margin: 5px 0;
    font-size: 14px;
    line-height: 1.4;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
        height: 100vh;
    }
    
    .left-panel,
    .right-panel {
        width: 100%;
        height: auto;
        max-height: 200px;
        overflow-y: auto;
    }
    
    .center-panel {
        flex: 1;
        min-height: 300px;
    }
    
    .product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .user-buttons {
        flex-direction: column;
        gap: 4px;
    }
    
    .action-buttons {
        flex-direction: row;
        gap: 6px;
    }
    
    .btn-primary,
    .btn-secondary,
    .btn-hint {
        flex: 1;
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* Touch-friendly adjustments */
@media (pointer: coarse) {
    .product-btn,
    .user-btn,
    .btn-primary,
    .btn-secondary,
    .btn-hint {
        min-height: 44px;
        min-width: 44px;
    }
    
    .zoom-btn {
        width: 44px;
        height: 44px;
    }
    
    .slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    
    .slider::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }
}